#include "NetworkIcon.h"
#include <qnetworkaccessmanager.h>
#include <qnetworkreply.h>
#include <qnetworkrequest.h>
#include <qpixmap.h>

NetworkIcon::NetworkIcon(QWidget *parent) : QWidget(parent) 
, pixmap(new QPixmap)
{
    QNetworkAccessManager *manager = new QNetworkAccessManager(this);;
    
    connect(manager, &QNetworkAccessManager::finished, [&](QNetworkReply *reply){
        QTextStream out(stdout);
        out << "Reply\n";
        // out <<  reply.
        pixmap->loadFromData(reply->readAll());

        emit loaded(*pixmap);
    });
    
    manager->get(QNetworkRequest(QUrl("https://dl.flathub.org/repo/logo.svg")));
}